# Archlive <http://archlive-pkg.googlecode.com>

pkgname=slim-archlive
_pkgname=slim
pkgver=1.3.1
pkgrel=1
pkgdesc="Simple Login Manager with changeable cursor and other patches"
arch=(i686 x86_64)
url="http://slim.berlios.de"
backup=(etc/slim.conf)
depends=(gcc-libs libxmu libxft libjpeg libpng bash pam)
provides=(slim)
conflicts=(slim)
install=slim.install
license=('GPL2')
source=(http://download.berlios.de/$_pkgname/$_pkgname-$pkgver.tar.gz
        slim slim.logrotate slim.pam slim.patch slim.patch2 slim.patch3
	slim.patch4 slim.patch5 slim-1.3.0-custom_keys.diff
	# Boot configuration files
	xinitrc xinitrc.afterstep xinitrc.awesome xinitrc.e16 xinitrc.e17 xinitrc.fluxbox xinitrc.gnome
	xinitrc.icewm xinitrc.kde xinitrc.lxde xinitrc.openbox xinitrc.xfce Xsession
	slim.conf archlive.tar.bz2
)

build() {

cd $srcdir/$_pkgname-$pkgver

# apply the cursor patch
patch -Np0 -i $srcdir/slim.patch
# xserver fix -- http://developer.berlios.de/patch/?func=detailpatch&patch_id=2378&group_id=2663
patch -Np1 -i $srcdir/slim.patch2
# pam_unix2 fix -- http://developer.berlios.de/patch/?func=detailpatch&patch_id=2698&group_id=2663
patch -Np1 -i $srcdir/slim.patch3
# kerberos fix -- http://developer.berlios.de/patch/?func=detailpatch&patch_id=2690&group_id=2663
patch -Np1 -i $srcdir/slim.patch4
# gcc 4.4 fix -- http://sources.gentoo.org/viewcvs.py/*checkout*/gentoo-x86/x11-misc/slim/files/slim-1.3.1-gcc4.4.patch?rev=1.1
patch -Np1 -i $srcdir/slim.patch5
# add optical keys
patch -Np1 -i "$srcdir/slim-1.3.0-custom_keys.diff"

make USE_PAM=1 || return 1
make DESTDIR=$startdir/pkg install

install -D -m755 -o root -g root $srcdir/slim $pkgdir/etc/rc.d/slim
install -D -m644 -o root -g root $srcdir/slim.logrotate $pkgdir/etc/logrotate.d/slim
install -D -m644 -o root -g root $srcdir/slim.pam $pkgdir/etc/pam.d/slim

for i in xinitrc xinitrc.afterstep xinitrc.awesome xinitrc.e16 xinitrc.e17 xinitrc.fluxbox \
	xinitrc.gnome xinitrc.icewm xinitrc.kde xinitrc.lxde xinitrc.openbox xinitrc.xfce; do
	install -Dm755 ${srcdir}/$i ${pkgdir}/etc/X11/xinit/$i
done
install -D -m755 -o root -g root $srcdir/slim.conf $pkgdir/etc/slim.conf
install -D -m755 -o root -g root $srcdir/Xsession $pkgdir/etc/X11/xdm/Xsession

# Archlive themes
rm -rf $pkgdir/usr/share/slim/themes/default
install -d -m755 $pkgdir/usr/share/slim/themes/archlive
cp $srcdir/archlive/* $pkgdir/usr/share/slim/themes/archlive/

# Provide sane defaults
sed -i 's|#xserver_arguments.*|xserver_arguments   -nolisten tcp vt07|' \
	"$pkgdir/etc/slim.conf" || return 1
sed -i 's|/var/run/slim.lock|/var/lock/slim.lock|' "$pkgdir/etc/slim.conf" || return 1
}
